home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 1.iso
/
toolbox
/
src
/
exampleCode
/
opengl
/
xlib
/
skeeter.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-11
|
24KB
|
1,015 lines
/*
* Copyright (c) 1993-94, Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the name of Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
* POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include "skeeter.h"
/*
* attribute list for an RGB double buffered visual, with
* red, green, blue, and depth components
*/
static int attributeList[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
None };
int REDRAW = True;
/*
* overlay plane visual attribute list
*/
static int al2[] = {GLX_LEVEL, 2, None };
/*
* popup plane visual attribute list
*/
static int al1[] = {GLX_LEVEL, 1, None };
/*
* function to wait for a window to map
*/
static Bool WaitForNotify (Display *d, XEvent *e, char *arg)
{
return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
}
/*
* functions in this file
*/
void drawScene(void);
void updateFlightParams(void);
void pull(void);
void drawCD(GLUquadricObj *);
void gluErrorHandler(void);
void makeCD(void);
void drawBackground(void);
void makeSkeeter(void);
void initStruct(void);
void newParams(int);
void parseArgs(int, char **);
void drawSkeeter(int, int, int, int);
main(int argc, char **argv)
{
XVisualInfo *vi; /* X Visual */
XVisualInfo *ovi; /* X Visual */
Colormap cmap, ocmap; /* X Colormap */
XSetWindowAttributes swa; /* X Window Attributes */
XEvent event; /* X event */
Window root_win;
char xlat[20];
int nchar = 20;
KeySym key;
XComposeStatus cs;
XWindowAttributes winattrs;
XColor spix, pixel;
float fx, fy;
int num;
XMotionEvent *motion;
XButtonEvent *button;
static char cur[] = {0x0f, 0x0f};
XColor color;
Pixmap source;
int looper, now;
if (argc >1)
parseArgs(argc, argv);
dpy = XOpenDisplay (0);
XSynchronize(dpy, True);
/*
* get a regular, double buffer, rgb visual
* if we can't get it, big trouble, so bail out!
*/
vi = glXChooseVisual (dpy, DefaultScreen(dpy), attributeList);
if (vi == NULL) {
printf("\n can't get requested visual type, bye...\n");
exit(0);
}
/*
* create a GLX context
*/
cx = glXCreateContext (dpy, vi, None, GL_TRUE);
/*
* create a colormap using this visual
*/
cmap = XCreateColormap (dpy, RootWindow(dpy, vi->screen), vi->visual,
AllocNone);
/*
*create an X Window
*/
swa.colormap = cmap;
swa.border_pixel = 1;
swa.event_mask = StructureNotifyMask;
source = XCreatePixmapFromBitmapData(dpy, DefaultRootWindow(dpy),
cur, 1, 1, 0, 0, 1);
swa.cursor = XCreatePixmapCursor(dpy, source, source,
&color, &color, 0, 0);
win = XCreateWindow (dpy, RootWindow(dpy,vi->screen),
0, 0, WINSIZE, WINSIZE,
0, vi->depth, InputOutput, vi->visual,
CWCursor | CWBorderPixel |
CWColormap|CWEventMask, &swa);
XMapWindow (dpy,win);
/*
* wait for window to map so that we can start drawing into
* it.
*/
XIfEvent(dpy, &event, WaitForNotify, (char *) win);
/*
* now try to create an overlay window
* the scheme is as follows:
* - first try to get a level 2 visual, one in the overlay planes.
* if that fails...
* - try to get a level 1 visual, one in the popup planes.
* if that fails, just do all drawing in the normal planes
*/
ovi = glXChooseVisual (dpy, DefaultScreen(dpy), al2);
if (ovi == NULL) {
printf("\n can't get requested overlay visual type...\n");
ovi = glXChooseVisual (dpy, DefaultScreen(dpy), al1);
if (ovi)
fprintf(stderr, "got popup plane window!\n");
}
else
fprintf(stderr, "got overlay plane window!\n");
if (ovi == NULL) {
printf("\n can't get popup visual either, using regular visual...\n");
}
if (ovi) {
USE_OVERLAY = True;
/*
* we have an overlay visual, so
* create a GLX context, along with the rest of the junk
* we need to create a window with this viusal
*/
ocx = glXCreateContext (dpy, ovi, None, GL_TRUE);
/* create a colormap using this visual */
ocmap = XCreateColormap (dpy, RootWindow(dpy, ovi->screen), ovi->visual,
AllocNone);
/* create a X Window */
swa.colormap = ocmap;
swa.border_pixel = 0;
swa.win_gravity = UnmapGravity;
swa.bit_gravity = NorthWestGravity;
swa.background_pixel = BlackPixel(dpy, ovi->screen);
owin = XCreateWindow (dpy, win, 0, 0, WINSIZE, WINSIZE,
0, ovi->depth, InputOutput, ovi->visual,
CWBorderPixel|CWColormap|CWEventMask, &swa);
XMapWindow (dpy,owin);
}
/* install the colormap windows property so that overlay colormap
* takes hold when we move cursor into window
*/
winList[0] = win;
winList[1] = owin;
if (USE_OVERLAY) {
winList[1] = owin;
num = 2;
}
else
num = 1;
XSetWMColormapWindows(dpy, win, winList, num);
/*
* get the 'white' pixel value, we will need this
* to set colormap index for overlay drawing
*/
if (USE_OVERLAY) {
XAllocNamedColor(dpy, ocmap, "white", &spix, &pixel);
WHITE_PIXEL_NUM = pixel.pixel;
XAllocNamedColor(dpy, ocmap, "RED", &spix, &pixel);
RED_PIXEL_NUM = pixel.pixel;
XAllocNamedColor(dpy, ocmap, "GRAY", &spix, &pixel);
BLACK_PIXEL_NUM = pixel.pixel;
}
/* connect the context to the window */
if (!glXMakeCurrent(dpy, win, cx) == GL_TRUE) {
return 0;
}
/*
* get the window size and location so that we can
* make the cylinder track the mouse movements *somewhat* acurately
*/
XGetWindowAttributes(dpy, win, &winattrs);
xorigin = winattrs.x;
yorigin = winattrs.y;
width = winattrs.width;
height = winattrs.height;
/*
* starting location of skeeter, my choice
*/
xloc = 100;
yloc = 100;
/*
* finally, some OpenGL stuff!!
* set up zbuffer depth test, projection & model matrices, light models,
* and don't forget to turn on the light!
*/
glViewport(0, 0, width, height);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
/*
* set up projection matrix; we will use perspective projection
* and set our eye point 10 z units away, in effect, you will be
* shootin' from your chair, dead on!
*/
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(95.0, 1.0, 0.5, ZDEPTH);
gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
/*
* perspective set, model matrix stuff from now on...
*/
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0, 0.0, -4.0);
/*
* let there be light!
*/
glLightfv(GL_LIGHT1, GL_POSITION, lpos);
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, specular);
glLightfv(GL_LIGHT2, GL_POSITION, l2_lpos);
glLightfv(GL_LIGHT2, GL_AMBIENT, l2_ambient);
glLightfv(GL_LIGHT2, GL_DIFFUSE, l2_diffuse);
glLightfv(GL_LIGHT2, GL_SPECULAR, l2_specular);
glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 45.0);
glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, l2_direction);
glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 80);
glLightfv(GL_LIGHT3, GL_POSITION, lpos);
glLightfv(GL_LIGHT3, GL_POSITION, l3_lpos);
glLightfv(GL_LIGHT3, GL_AMBIENT, l3_ambient);
glLightfv(GL_LIGHT3, GL_DIFFUSE, l3_diffuse);
glLightfv(GL_LIGHT3, GL_SPECULAR, l3_specular);
glLightf(GL_LIGHT3, GL_SPOT_CUTOFF, 90.0);
glLightf(GL_LIGHT3, GL_SPOT_EXPONENT, 100);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, alm);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT3);
if (num_lights > 1)
glEnable(GL_LIGHT2);
if (num_lights > 2)
glEnable(GL_LIGHT3);
/*
* now set up the matrix stuff for the overlay window.
* since not much going on here as far as 3D stuff,
* just keep it simple, -1 to +1 in X and Y, no Z component
* since we don't do any depth stuff in the overlay planes
* anyway
*/
if (USE_OVERLAY) {
glXMakeCurrent(dpy, owin, ocx);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1, 1, -1, 1, 0, 0);
glMatrixMode(GL_MODELVIEW);
}
/*
* set X input stuff
*/
XSelectInput(dpy, win, ExposureMask |StructureNotifyMask |
ButtonPressMask | Button1MotionMask |
SubstructureNotifyMask | KeyPressMask |
KeyReleaseMask | ButtonReleaseMask );
if (USE_OVERLAY)
XSelectInput(dpy, owin, ExposureMask |StructureNotifyMask |
ButtonPressMask | Button1MotionMask |
SubstructureNotifyMask | KeyPressMask |
KeyReleaseMask | ButtonReleaseMask );
/*
* if we are not using overlay drawing, set the overlay drawing
* window to the main planes window
*/
if (!USE_OVERLAY) {
owin = win;
ocx = cx;
}
glXMakeCurrent(dpy, win, cx);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
makeCD();
if (DO_BACKGROUND)
drawBackground();
glXSwapBuffers(dpy, win);
glXMakeCurrent(dpy, owin, ocx);
makeSkeeter();
glXMakeCurrent(dpy, win, cx);
/*
* initialize data structures
*/
initStruct();
/*
* the dreaded X Event loop...
*/
looper = now = 0;
while (1) {
if (XPending(dpy)) {
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
glXMakeCurrent(dpy, owin, ocx);
glClearIndex(0);
glClear(GL_COLOR_BUFFER_BIT);
drawScene();
drawSkeeter(xloc, yloc, WHITE_PIXEL_NUM, True);
break;
case ConfigureNotify:
{
int newwidth, newheight;
/*
* get window size in case of a resize...
*/
XGetWindowAttributes(dpy, win, &winattrs);
xorigin = winattrs.x;
yorigin = winattrs.y;
width = winattrs.width;
height = winattrs.height;
/*
* clear overlay window
*/
if (USE_OVERLAY) {
XResizeWindow(dpy, owin, width, height);
glXMakeCurrent(dpy, owin, ocx);
glViewport(0, 0, width, height);
drawSkeeter(xloc, yloc, WHITE_PIXEL_NUM, True);
}
glXMakeCurrent(dpy, win, cx);
glViewport(0, 0, width, height);
}
now = True;
break;
case ButtonPress:
button = (XButtonEvent *) &event;
drawSkeeter(button->x, button->y, RED_PIXEL_NUM, True);
REDRAW = False;
break;
case ButtonRelease:
REDRAW = True;
break;
case KeyPress:
XLookupString((XKeyEvent *) &event, xlat, nchar, &key, &cs);
switch (key) {
case XK_Escape:
printf("\n bye...\n");
exit(0);
break;
case XK_space:
pull();
break;
}
break;
case MotionNotify:
motion = (XMotionEvent *) &event;
drawSkeeter(motion->x, motion->y, WHITE_PIXEL_NUM, False);
xloc = motion->x;
yloc = motion->y;
break;
default:
break;
}
}
if (REDRAW) {
updateFlightParams();
drawScene();
}
}
}
/*
* routine to draw the SKEETER, in the overlay planes if
* available
*/
GLUquadricObj *head, *rightEye, *leftEye, *body1, *body2, *body3;
void
drawSkeeter(int ix, int iy, int color, int now)
{
static int doMe = 1;
int i;
float x, y;
float v[2];
/*
* little slight-of-hand here. X generates a truck load of events
* for cursor movements. to get good performance, we will only process
* say every 10th cursor motion event, unless we are directed to do it
* 'now'. an example of when we would want to redraw cross hair 'now'
* would be when the window is resized
*
*/
if (!now) {
doMe++;
if ((doMe % 10) != 0)
return;
else
doMe = 1;
}
/*
* we need to map the X window x and y coordinates to fit into
* our overlay window space -1 to 1 in both X and Y
*/
x = (float) ((((float) ix) - (((float)width)/2.0)) / (((float)width)/2.0));
y = (float) (( (((float)height)/2.0) - ((float) iy)) / (((float)height)/2.0));
/*
* make overlay window current and clear
*/
glXMakeCurrent(dpy, owin, ocx);
if (USE_OVERLAY) {
glClearIndex(0);
glClear(GL_COLOR_BUFFER_BIT);
glIndexi(color);
}
else
glColor3b(1, 0, 0);
/*
* push down a matrix, multiply in a translation to current X and Y
* positions and call the SKEETER display list
*/
glPushMatrix();
glTranslatef(x, y, 0.0);
glCallList(SKEETER_LIST);
glPopMatrix();
}
/*
* routine to make a 'skeeter display list
*/
void
makeSkeeter()
{
glNewList(SKEETER_LIST, GL_COMPILE);
glPushMatrix();
glScalef(.1, .1, .0);
if (!head)
head = gluNewQuadric();
if (!rightEye)
rightEye = gluNewQuadric();
if (!leftEye)
leftEye = gluNewQuadric();
if (!body1)
body1 = gluNewQuadric();
if (!body2)
body2 = gluNewQuadric();
if (!body3)
body3 = gluNewQuadric();
gluQuadricCallback(rightEye, GLU_ERROR, gluErrorHandler);
gluQuadricCallback(leftEye, GLU_ERROR, gluErrorHandler);
gluQuadricCallback(head, GLU_ERROR, gluErrorHandler);
gluQuadricCallback(body1, GLU_ERROR, gluErrorHandler);
gluQuadricCallback(body2, GLU_ERROR, gluErrorHandler);
gluQuadricCallback(body3, GLU_ERROR, gluErrorHandler);
glIndexi(BLACK_PIXEL_NUM);
gluDisk(head, 0.0, 0.5, 10.0, 10.0);
glIndexi(RED_PIXEL_NUM);
glPushMatrix();
glTranslatef(-0.2, 0.4, 0.0);
gluDisk(rightEye, 0.0, 0.25, 10.0, 10.0);
glPopMatrix();
glPushMatrix();
glTranslatef(-0.2, -0.4, 0.0);
gluDisk(leftEye, 0.0, 0.25, 10.0, 10.0);
glPopMatrix();
glIndexi(BLACK_PIXEL_NUM);
glPushMatrix();
glTranslatef(0.5, 0.0, 0.0);
gluDisk(body1, 0.0, 0.4, 10.0, 10.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.9, 0.0, 0.0);
gluDisk(body2, 0.0, 0.4, 10.0, 10.0);
glPopMatrix();
glPushMatrix();
glTranslatef(1.3, 0.0, 0.0);
gluDisk(body3, 0.0, 0.4, 10.0, 10.0);
glPopMatrix();
glBegin(GL_LINES);
glVertex3f(0.4, 0.0, 0.0);
glVertex3f(0.6, 1.0, 0.0);
glVertex3f(0.4, 0.0, 0.0);
glVertex3f(0.6, -1.0, 0.0);
glVertex3f(0.9, 0.0, 0.0);
glVertex3f(1.1, 1.0, 0.0);
glVertex3f(0.9, 0.0, 0.0);
glVertex3f(1.1, -1.0, 0.0);
glVertex3f(1.3, 0.0, 0.0);
glVertex3f(1.5, 1.0, 0.0);
glVertex3f(1.3, 0.0, 0.0);
glVertex3f(1.5, -1.0, 0.0);
glEnd();
glIndexi(WHITE_PIXEL_NUM);
glBegin(GL_TRIANGLES);
glVertex3f(0.5, 0.2, 0.0);
glVertex3f(1.0, 0.2, 0.0);
glVertex3f(2.0, 0.9, 0.0);
glVertex3f(0.5, -0.2, 0.0);
glVertex3f(1.0, -0.2, 0.0);
glVertex3f(2.0, -0.9, 0.0);
glEnd();
glPopMatrix();
glPopMatrix();
glEndList();
}
float rotAngle = 0.0;
/*
* update the scene. first clear back and z buffers, then draw the
* cd
*/
void
drawScene()
{
int i;
glXMakeCurrent(dpy, win, cx);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
rotAngle+=15;
if (DO_BACKGROUND)
glCallList(BACKGROUND_LIST);
for (i = 0; i < num_cd; i++) {
glPushMatrix();
glTranslatef(cd_info[i].posX, cd_info[i].posY, cd_info[i].posZ);
glRotatef(rotAngle, 1.0, 0.0, 0.0);
glCallList(CD1_LIST);
glPopMatrix();
}
glXSwapBuffers(dpy, win);
}
/*
* draw a cd. a cd consists of several disks. the big one is shiny silver,
* the others are supposed to be clear plastic, so we will use alpha
* blending transparency
*/
void
drawCD(GLUquadricObj *cp)
{
if (!cp) {
cp = gluNewQuadric();
gluQuadricCallback(cp, GLU_ERROR, gluErrorHandler);
}
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mdiffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mspecular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
gluDisk(cp, 2.0, 5.0, 50.0, 50.0);
/*
* enable alpha blending to simulate the clear plastic part
* of the cd in the center and the outer edge
*/
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ma2);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, md2);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ms2);
gluDisk(cp, 5.0, 5.25, 50.0, 50.0);
gluDisk(cp, 0.9, 1.75, 50.0, 50.0);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
void
gluErrorHandler()
{
fprintf(stderr, "%s\n", gluErrorString(glGetError()));
}
void
makeCD()
{
glNewList(CD1_LIST, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT, gambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, gdiffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, gspecular);
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
drawCD(cp1);
glEndList();
}
void
pull()
{
/*
* start raining cdroms down
*/
updateFlightParams();
}
#include <time.h>
void
updateFlightParams()
{
int i;
for (i = 0; i < num_cd; i++) {
if (cd_info[i].state == NONE)
newParams(i);
if (cd_info[i].posZ <= -85) {
cd_info[i].state = NONE;
newParams(i);
}
cd_info[i].posZ += cd_info[i].ZInc;
}
}
/*
* the checkerboard background
*/
void
drawBackground()
{
float i, j, next;
next = True;
glNewList(BACKGROUND_LIST, GL_COMPILE);
glDisable(GL_LIGHTING);
glBegin(GL_QUADS);
for (j = -100; j < 100; j+=10) {
for (i = -100; i < 100; i+=10) {
if (next) {
glColor3f(0.31, 0.16, 1.0);
next = !next;
}
else {
glColor3f(0.15, 0.15, 1.0);
next = !next;
}
glVertex3f(i, j, -85.0);
glVertex3f(i+10.0, j, -85.0);
glVertex3f(i+10.0, j+10.0, -85.0);
glVertex3f(i, j+10.0, -85.0);
}
next = !next;
}
glEnd();
glEnable(GL_LIGHTING);
glEndList();
}
void
initStruct()
{
int i;
for (i = 0; i < MAX_DROPS; i++) {
cd_info[i].state = NONE;
}
}
void
newParams(int ix)
{
time_t tloc;
double x, y, z;
long xt, yt, zt;
static int firstTime = 0;
if (!firstTime) {
time(&tloc);
srandom((long) tloc);
firstTime = 1;
}
x = random();
y = random();
z = random();
xt = (x / 100.0);
xt = xt * 100;
x = (x - xt)/10;
yt = (y / 100.0);
yt = yt * 100;
y = (y - yt)/10;
zt = (z / 100.0);
zt = zt * 100;
z = (z - zt)/10;
cd_info[ix].XInc = x/10;
cd_info[ix].YInc = y/10;
cd_info[ix].ZInc = -z/10;
/*
* for some variety, if x is od, start at a negative X position
*/
if ((((int)x) % 2) != 0)
cd_info[ix].posX = -x;
else
cd_info[ix].posX = x;
/*
* for some variety, if y is even, start at a negative Y position
*/
if ((((int)y) % 2) != 0)
cd_info[ix].posY = y;
else
cd_info[ix].posY = -y;
cd_info[ix].posZ = 10;
cd_info[ix].state = FALLING;
#ifdef DEBUG
fprintf(stderr, "\n new cd[%d] posX: %f posY: %f posZ: %f\n",
ix,cd_info[ix].posX, cd_info[ix].posY,cd_info[ix].posZ);
fprintf(stderr, "\n XInc: %f YInc: %f ZInc: %f\n",
cd_info[ix].XInc, cd_info[ix].YInc,cd_info[ix].ZInc);
#endif
}
void
parseArgs(int argc, char **argv)
{
int i, argOk;
argOk = False;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-nb") == 0) {
DO_BACKGROUND = False;
argOk = True;
}
if (strcmp(argv[i], "-n") == 0) {
if (i+1 < argc) {
num_cd = atoi(argv[i+1]);
i++;
}
else
num_cd = 0;
if ((num_cd > 0) && (num_cd <= MAX_DROPS))
argOk = True;
}
if (strcmp(argv[i], "-l") == 0) {
if (i+1 < argc) {
num_lights = atoi(argv[i+1]);
i++;
}
else
num_lights = 0;
if ((num_lights > 0) && (num_lights <= MAX_LIGHTS))
argOk = True;
}
if (argOk != True) {
fprintf(stderr,
"\nusage: %s [-nb -n <number of cd's> -l <number of lights>]\n"
, argv[0]);
exit(0);
}
}
}